<!--
 * @Author: 涵崽
 * @Date: 2024-02-28 14:44:38
 * @email: 1045654@qq.com
 * @gitee: https://gitee.com/han-zai
 * @LastEditors: 涵崽
 * @LastEditTime: 2024-02-29 15:01:37
 * @Description: 微信：1045654
-->
<template>
  <div class="pagination">
    <el-pagination
      :current-page="page"
      :page-sizes="pageSizes"
      :page-size="limit"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  name: 'Pagination',
  inject: ['init'],
  props: {
    total: {
      required: true,
      type: Number
    }, // 数据总数
    page: {
      type: Number,
      default: 1
    }, // 当前页数
    limit: {
      type: Number,
      default: 10
    }, // 每页显示条目个数
    pageSizes: {
      type: Array,
      default() {
        return [10, 20, 30, 50]
      }
    } // 设置一次展示多少行数据
  },
  data() {
    return {}
  },
  methods: {
    handleSizeChange(val) {
      this.$emit('update:limit', val)
      this.init()
    },
    handleCurrentChange(val) {
      this.$emit('update:page', val)
      this.init()
    }
  }
}
</script>

<style lang="scss">
.pagination {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.el-pagination button:disabled,
.el-pagination .btn-next,
.el-pagination .btn-prev,
.el-pager li {
  background-color: rgba($color: #fff, $alpha: 0) !important;
}
</style>
